/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package jse.thread;

import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Swang
 * 同一实例对象的方法的可以并发执行
 */
public class FunctionCall {

    class Thread1 extends Thread {

        @Override
        public void run() {
            System.out.println("Thread1 begin at " + new Date());
            test("test");
            System.out.println("Thread1 begin end " + new Date());
        }
    }

    public void test(String param) {
        System.out.println(this.toString());
        System.out.println(param);
        try {
            Thread.sleep(5000);
        } catch (InterruptedException ex) {
            Logger.getLogger(FunctionCall.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public static void main(String[] args) {
        FunctionCall fc1 = new FunctionCall();
        FunctionCall fc2 = new FunctionCall();
        FunctionCall.Thread1 t1 = fc1.new Thread1();
        t1.start();
        FunctionCall.Thread1 t2 = fc1.new Thread1();
        //FunctionCall.Thread1 t2 = fc2.new Thread1();
        t2.start();
    }
}
